﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Input;
using System.Collections.Generic;
using MichMan.Utilities;
using System.Xml.Linq;
using System.Xml;

namespace Subsonic.Resources
{
    /// <summary>
    /// Helper class for string resources.
    /// </summary>
    public static class StringTable 
    {
        public static string StaticResource(this string value)
        {
            string s = StaticResource<string>(value);
            if (s == null)
            {
                return value;
            }
            return s;
        }

        /// <summary>
        /// There's probably some silverlight standard way to do this of which I am unaware.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static T StaticResource<T>(this string value) where T : class
        {
            if (value != null && value.StartsWith("{") && value.EndsWith("}"))
            {
                var v = value.Substring(1, value.Length - 2);
//                if (Application.Current.Resources[v] == null)
                {
                    return default(T);
                }
  //              else
                {
    //                return Application.Current.Resources[v] as T;
                }
            }
            else
            {
                return default(T);
            }
        }
    }

    /// <summary>
    /// Class for importing plural from android resources.
    /// 
    /// Android Strings and plurals are transformed into Xaml via XSLT.
    /// </summary>
    public class Plural
    {
        public string Zero { get; set; }
        public string One { get; set; }
        public string Other { get; set; }
    }
}
